<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>donw2-多文件演示页面</title>
    <script type="text/javascript" src="js/jquery-1.4.min.js"></script>
    <script type="text/javascript" src="js/down.js" charset="utf-8"></script>
    <script type="text/javascript" src="js/demo.js" charset="utf-8"></script>
    <style type="text/css">
        h5 {margin:0;font-family: 微软雅黑 宋体;}
        p {font: 9pt 宋体;}
        ul {list-style-type: none;font: 9pt 宋体;}
        ul li {display: inline;margin: 0 5px 0 0;font: 9pt 宋体;}
    </style>
</head>
<body>
<h5>自定义下载目录名称。</h5>
<div id="demos"></div>
<input type="button" value="下载文件夹" id="btn-down-json" />
<div id="downDiv"></div>
<script type="text/javascript" language="javascript">
    //根路径：http://localhost/api/up6/
    var pos = window.location.href.lastIndexOf("json.htm");
    var api = window.location.href.substr(0, pos)+"db/api/";
    var downer = new DownloaderMgr({
        config: {
            License2:"",//请在此处配置授权码
            Folder: "",
            DataBase: false,//启用数据库支持
            //api
            "UrlCreate": api + "d_create.php",
            "UrlDel": api + "d_del.php",
            "UrlList": api + "d_list.php",
            "UrlUpdate": api + "d_update.php",
            "UrlDown": api + "down.php"
        },
        event: {
            taskCreate: function (obj) {
                $(document.body).append("<div>文件ID：" + obj.fileSvr.id) + "</div>";

                //自动下载
                setTimeout(function () {
                    if (obj.fields.auto=="1") downer.start_queue();
                }, 300);
            },
            downProcess: function (obj) { },
            downStoped: function (obj) { },
            downComplete: function (obj) {
                $(document.body).append('<div>本地路径：' + obj.fileSvr.pathLoc + '</div>');
            },
            downError: function (obj, err) { },
            queueComplete: function () {
                $(document.body).append("<div>队列完成</div>");
            },
            //ready: function () { },
            selFolder: function (dir) {
                setTimeout(function(){
                    if(downer.data.cur!=null)
                    {
                        downer.addJson(downer.data.cur);
                        downer.data.cur = null;
                    }
                },100);
            }
        },
        ui: { render:"downDiv"}
    });

    $(function () {
        $("#btn-down-json").click(function () {
            var fd = {
                nameLoc: "图片列表",
                fields:{auto:"1"/*自动下载标识*/},
                files: [
                    { fileUrl: "http://res2.ncmem.com/res/images/ie11.png" },
                    { fileUrl: "http://res2.ncmem.com/res/images/up6.1/down.png" },
                    { fileUrl: "http://res2.ncmem.com/res/images/firefox.png" },
                    { fileUrl: "http://res2.ncmem.com/res/images/edge.png" },
                    { fileUrl: "http://res2.ncmem.com/res/images/up6.1/cloud.png" },
                    { fileUrl: "http://res2.ncmem.com/res/images/home/w.png" },
                    { fileUrl: "http://res2.ncmem.com/res/images/img.png" }
                ]
            };
            if (downer.Config["Folder"] == "") {
                downer.data.cur = fd;
                downer.openFolder();
                return;
            }
            downer.addJson(fd);
        });
    });
</script>
</body>
</html>